package com.genesis.yunnanji.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;


public class ClassifySortAdapter extends FragmentPagerAdapter {

    private ArrayList<String> titles;

    private List<Fragment> mFragments;

    public ClassifySortAdapter(FragmentManager fm,List<Fragment> mFragments, ArrayList<String> list) {
        super(fm);
        this.mFragments = mFragments;
        this.titles = list;
    }

    public ClassifySortAdapter(FragmentManager fm,List<Fragment> mFragments) {
        super(fm);
        this.mFragments = mFragments;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles.get(position);
    }

    @Override
    public Fragment getItem(int position) {
        return this.mFragments == null ? null : (Fragment)this.mFragments.get(position);
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        return super.instantiateItem(container, position);
    }

    @Override
    public int getCount() {
        return this.mFragments == null ? 0 : this.mFragments.size();
    }
}
